//
//  CZComposeButton.swift
//  CZVVeiBo
//
//  Created by smile on 2017/8/5.
//  Copyright © 2017年 itcast. All rights reserved.
//

import UIKit

class CZComposeButton: UIButton {
    
    // 添加一个模型属性
    var composeModel: CZComposeModel?
    
    // 取消按钮的高亮效果
    override var isHighlighted: Bool{
        get{
            return false
        }
        
        set{
        }
        
    }

    override init(frame: CGRect) {
        super.init(frame: frame)
        seutpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - 设置视图
    private func seutpUI(){
//        backgroundColor = randomColor()
        // 图片的填充方式
        imageView?.contentMode = .center
        // 设置文字
        titleLabel?.font = UIFont.systemFont(ofSize: 14)
        titleLabel?.textAlignment = .center
        setTitleColor(UIColor.darkGray, for: UIControlState.normal)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        // 重新设置frame
        self.imageView?.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.width)
        self.titleLabel?.frame = CGRect(x: 0, y:  self.frame.width, width:  self.frame.width, height: self.frame.height -  self.frame.width)
        
    }

}
